/**
 * @author Luc Yriarte
 * 
 * Licence : BSD http://www.opensource.org/licenses/bsd-license.php
 *  
 */

package basicSim;

import java.awt.Graphics;
import java.awt.Polygon;

/**
 * The awt Polygon links the last point to the first.
 */
public class PolygonEdgeIndexes {

	public Object3D obj;

	public int z = 0;

	public int nEdge = 0;

	public int edge[] = null;

	public Polygon polygon;

	public PolygonEdgeIndexes(Object3D o, int n) {
		obj = o;
		nEdge = n;
		edge = new int[n];
		z = 0;
	}

	public void updatePolygon() {
		int i;
		int xP[] = new int[nEdge];
		int yP[] = new int[nEdge];
		z = 0;
		for (i = 0; i < nEdge; i++) {
			xP[i] = obj.wireframe[edge[i]][0];
			yP[i] = obj.wireframe[edge[i]][1];
			z += obj.wireframe[edge[i]][4];
		}
		polygon = new Polygon(xP, yP, nEdge);
		z /= nEdge;
	}

	public void updatePolygon(int xP[], int yP[]) {
		polygon = new Polygon(xP, yP, nEdge);
	}

	public void paint(Graphics g) {
		g.fillPolygon(polygon);
	}

}
